﻿package mortal.game.view.systemSetting
{
    import com.gengine.core.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import com.mui.events.*;
    import com.mui.utils.*;
    import mortal.component.window.*;
    import mortal.game.view.common.*;
    import mortal.game.view.systemSetting.view.*;
    import mortal.game.view.wizard.*;
    import mortal.mvc.interfaces.*;

    public class SystemSettingModule extends BaseWindow
    {
        protected var _tabBar:GTabarNew;
        protected var _systemSetPanel:SystemSetPanel;
        protected var _shortcutsPanel:ShortcutsPanel;
        protected var _lastIndex:int;
        private var _swfPlayerInfoTF:GTextFiled;

        public function SystemSettingModule(param1:ILayer = null)
        {
            super(param1);
            setSize(495, 440);
            title = "系统";
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            var _loc_1:* = new Array({label:"系统设置", name:"systemSet"}, {label:"快捷键", name:"shortCuts"});
            this._tabBar = UIFactory.gTabBarNew(2, 32, _loc_1, 495, 440, 76, 28, this, this.onTabBarChange);
            this._swfPlayerInfoTF = UIFactory.gTextField("", 300, 37, 200, 20, this);
            pushUIToDisposeVec(this._swfPlayerInfoTF);
            this._systemSetPanel = UICompomentPool.getUICompoment(SystemSetPanel);
            this.addChild(this._systemSetPanel);
            this._lastIndex = 0;
            this.updateSwfPlayerInfo();
            return;
        }// end function

        public function updateSwfPlayerInfo() : void
        {
            var _loc_1:String = null;
            if (this._swfPlayerInfoTF)
            {
                _loc_1 = "播放器:" + FlashVersion.instance.getVersionStr();
                _loc_1 = _loc_1 + ("  显卡:" + FrameUtil.driveInfo);
                this._swfPlayerInfoTF.text = _loc_1;
            }
            return;
        }// end function

        protected function onTabBarChange(event:MuiEvent) : void
        {
            this.disposeLastPanel();
            switch(this._tabBar.selectedIndex)
            {
                case 0:
                {
                    if (!this._systemSetPanel)
                    {
                        this._systemSetPanel = UICompomentPool.getUICompoment(SystemSetPanel);
                        this.addChild(this._systemSetPanel);
                    }
                    this._lastIndex = 0;
                    break;
                }
                case 1:
                {
                    if (!this._shortcutsPanel)
                    {
                        this._shortcutsPanel = UICompomentPool.getUICompoment(ShortcutsPanel);
                        this.addChild(this._shortcutsPanel);
                    }
                    this._lastIndex = 1;
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        protected function disposeLastPanel() : void
        {
            switch(this._lastIndex)
            {
                case 0:
                {
                    this._systemSetPanel.dispose();
                    this._systemSetPanel = null;
                    break;
                }
                case 1:
                {
                    this._shortcutsPanel.dispose();
                    this._shortcutsPanel = null;
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._tabBar.dispose(param1);
            this._tabBar = null;
            if (this._systemSetPanel)
            {
                this._systemSetPanel.dispose(param1);
                this._systemSetPanel = null;
            }
            if (this._shortcutsPanel)
            {
                this._shortcutsPanel.dispose(param1);
                this._shortcutsPanel = null;
            }
            this._lastIndex = 0;
            return;
        }// end function

    }
}
